#!/usr/bin/env bash
# golang

if [[ -z "${c_golang}" ]]; then
    f_info 'golang: not install';
    echo > /dev/null;  return;
fi;

ins="${INS}/golang";  ov=`cat "${ins}/.version" 2>/dev/null`;
if [[ "${ov}" = "${c_golang}" ]]; then f_info "golang: has v${c_golang}";
else
    f_wait "golang: v${c_golang}";  n="golang-${c_golang}.tgz";
    u="https://dl.google.com/go/go${c_golang}.linux-amd64.tar.gz"
    f_down 'golang' "${n}" "${u}";
    cd "${INS}" || f_fail 'golang: cd to INS';
    rm -rf "${ins}"* || f_fail 'golang: del old';
    tar xzf "${TMP}/${n}" || f_fail 'golang: tar xzf';
    mv 'go' "${ins}" || f_fail 'golang: mv source';
    echo "${c_golang}" > "${ins}/.version" || f_fail 'golang: save version';
fi;

echo > /dev/null;
